import { EquipmentType } from "@/pages/station/stubList/services"
import request from "@/utils/request"

export enum BigChargeOrderStatus {
  进行中 = 1,
  '完成充电(待支付)' = 2,
  '完成充电(已支付)' = 3,
}

export enum BigChargeOrderInfoType {
  企业充电 = 1,
  个人充电 = 2,
}

export enum BigChargeOrderPayType {
  企业余额 = 1,
  个人余额 = 2 | 3 | 4,
}

export interface QueryBigChargeOrderListParams extends PaginationParams {
  /** 订单号 */
  id?: string
  status?: BigChargeOrderStatus
  stationId?: string
  carPlat?: string
  vin?: string
  equipmentId?: string
  stubId?: string
  infoType?: BigChargeOrderInfoType
  telephone?: string
  /** 开始充电时间 */
  beginTime?: string
  /** 结束充电时间 */
  endTime?: string
}

export interface BigChargeOrder {
  /** 开始充电时间 */
  beginTime: string
  carBrand: string
  carPlat: string
  carSeries: string
  carType: string
  cityName: string
  commend: string
  createTime: string
  /** 电流（充电中展示) */
  current: number
  /** 优惠金额 */
  cutMoney: number
  /** 优惠后的金额 */
  discountM: number
  /** 充电量（度） */
  electric: number
  /** 充完电量比例 */
  electricEnd: number
  /** 电费 */
  electricFee: number
  /** 充前电量比例 */
  electricStart: number
  /** 停止码 */
  endCode: string
  /** 结束充电时间 */
  endTime: string
  /** 停车位免费时长 */
  freeTime: number
  /** 订单号 */
  id: string
  /** 评价时间 */
  judgeTime: string
  /** 额定功率 */
  kw: number
  nickname: string
  /** 结算方式 */
  payType: BigChargeOrderPayType
  /** 付款截止日期 */
  paymentDeadline: string
  /** 评价图片, 逗号分隔 */
  pics: string
  /** 实付金额 */
  realPay: number
  /** 回复评论内容 */
  reply: string
  score: number
  serviceFee: number
  stationName: string
  status: BigChargeOrderStatus
  stubId: string
  /** 用户头像 */
  userImg: string
  /** 电压（充电中展示） */
  voltage: number
  infoType: BigChargeOrderInfoType
  telephone: string
  socBegin: number
  socEnd: number
  orgName: string
  paymentTime: string
  /** 设备类型 */
  stubType: EquipmentType
  /** 停止原因 */
  endName: string
}

export async function queryBigChargeOrderList(params: QueryBigChargeOrderListParams) {
  return request<BigChargeOrder[]>('/app/manager/chargeOrder/list', {
    data: params, token: localStorage.Authorization2
  })
}

export async function getBigChargeOrderDetail(params: {
  id: string
  infoType: number // 1 充电订单 2 占用订单 3 企业充电订单
}) {
  return request<BigChargeOrder>('/app/manager/chargeOrder/detail', {
    data: params, token: localStorage.Authorization2
  })
}

export interface ChargingHistory {
  current: number
  currentCar: number
  power: number
  soc: number
  tempCar: number
  tempEquipment: number
  tempStub: number
  time: number
  voltage: number
  voltageCar: number
}
export async function getChargingHistory(params: {
  id: string
}) {
  return request<ChargingHistory[]>('/app/manager/chargeOrder/his', {
    data: params, token: localStorage.Authorization2
  })
}
